/**
 * Copyright 2011 HNB. All rights reserved.
 * HNB PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package my.hnb.android.dto;

import java.io.Serializable;

import my.hnb.android.common.AppInfo;
import my.hnb.android.ultils.Encryption;
import my.hnb.android.ultils.StringUtil;

import android.database.Cursor;

/**
 * Thong tin mot bai nhac chi tiet
 * @author BANGHN
 */
@SuppressWarnings("serial")
public class SongDetailDTO implements Serializable{
	//ma bai hat
	public long songNumber;
	//ten bai hat
	public String songName;
	//loi ngan gon
	public String shortLyric;
	//loi full bai hat
	public String fullLyric;
	//thong tin nhac si
	public String musican;
	//ca si trinh bay
	public String singer;
	//thong tin loi soan
	public String lyrican;
	//thong tin ablum
	public String vol;
	//thong tin the loai
	public String type;
	public String[] arrayType;
	//favorite
	public int favorite = 0;
	
	
	public SongDetailDTO(){
		
	}

	/**
	 * Methods descriptions
	 * @author BANGHN
	 * @param c
	 */
	public void parseSongDetailInfo(Cursor c) {
		if(c != null){
			songNumber = c.getLong(c.getColumnIndex("SONG_NUMBER"));
			songName = c.getString(c.getColumnIndex("SONG_NAME"));
			fullLyric = c.getString(c.getColumnIndex("FULL_LYRIC"));
			if(!StringUtil.isNullOrEmpty(fullLyric)){
				fullLyric = new Encryption().decrypt(AppInfo.K_LYRIC, fullLyric).trim();
			}
			musican = c.getString(c.getColumnIndex("MUSICAN"));
			singer = c.getString(c.getColumnIndex("SINGER"));
			vol = c.getString(c.getColumnIndex("VOL"));
			favorite = c.getInt(c.getColumnIndex("FAVORITE"));
			//lyrican = c.getString(c.getColumnIndex("LYRICAN"));
			try {
				String tmp = c.getString(c.getColumnIndex("TYPE"));
				int size = AppInfo.getInstance().getMusicTypeOption().size();
				if(!StringUtil.isNullOrEmpty(tmp)){
					arrayType = c.getString(c.getColumnIndex("TYPE")).split(",");
					if (arrayType.length == 1) {
//						for(OptionItemDTO item: AppInfo.getInstance().getMusicTypeOption()){
//							if(item.value == Integer.parseInt(arrayType[0])){
//								type = item.strText;
//								break;
//							}
//						}
						type = AppInfo.getInstance().getMusicTypeOption().get(size - Integer.parseInt(arrayType[0])).strText;
					} else if (arrayType.length == 2) {
//						for(OptionItemDTO item: AppInfo.getInstance().getMusicTypeOption()){
//							if(item.value == Integer.parseInt(arrayType[0])){
//								type = item.strText;
//								break;
//							}
//						}
						type = AppInfo.getInstance().getMusicTypeOption().get(size - Integer.parseInt(arrayType[0])).strText;
						type += ", "
								+ AppInfo.getInstance().getMusicTypeOption().get(size - Integer.parseInt(arrayType[1])).strText;
					}
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}
